using System;
using System.Collections.Generic;
using System.Text;
using HermesPortal.Core.DAO;  
namespace HermesPortal.Core
{
    public class UserServices
    {

        /// <summary>
        ///  Returns a Creator with out any Saga role info
        /// </summary>
        /// <param name="creatorId"></param>
        /// <returns></returns>
        public static Creator GetCreator(int creatorId)
        {
             Creator creator = UserDAO.GetCreator(creatorId); 
            return creator; 
        }

        public static List<Creator> GetCreatorsBySagaID(int sagaID)
        {
            return UserDAO.GetCreatorsBySaga(sagaID);  
        }

        public static List<Creator> GetCreators()
        {
            return UserDAO.GetCreators();  
        }


        public static Creator GetCreatorByUserName(string userName)
        {
            return UserDAO.GetCreatorByUserName(userName);    
        }

        /// <summary>
        /// Returns a Creator with Role in current saga.
        /// </summary>
        /// <param name="creatorId"></param>
        /// <param name="sagaId"></param>
        /// <returns></returns>
        public static Creator GetCreatorBySaga(int creatorId, int sagaId)
        {
            return UserDAO.GetCreatorBySaga(creatorId, sagaId);    
        }

        public static void AddCreator(string userName, string applicationName)
        {
            UserDAO.AddCreator(userName, applicationName ); 
        }
        public static void UpdateCreator(Creator creator)
        {
            UserDAO.UpdateCreator(creator);  
        }
        /// <summary>
        /// Set the role of a creator within a saga.
        /// </summary>
        /// <param name="creatorId"></param>
        /// <param name="sagaId"></param>
        /// <param name="sagaRoleId"></param>
        public static void SetCreatorRoleForSaga(int creatorId, int sagaId, int sagaRoleId)
        {
            UserDAO.SetCreatorRoleForSaga(creatorId, sagaId, sagaRoleId);   
        }

        public static void SetCreatorRoleForSaga(int creatorId, int sagaId, string sagaRoleName)
        {
            int sagaRoleId = (int) Enum.Parse(typeof(SagaRoles), sagaRoleName);  
            UserDAO.SetCreatorRoleForSaga(creatorId, sagaId, sagaRoleId);
        }

        public static SagaRoles GetCreatorRoleForSaga(int creatorId, int sagaId)
        {

            return (SagaRoles)Enum.Parse(typeof(SagaRoles), UserDAO.GetCreatorRoleForSaga(creatorId, sagaId).ToString());
        }

      

     
    }
}
